package com.xiexie.order.service;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.stereotype.Service;

/**
 * @Description
 * @Date 2022-04-13 15:24
 * @Author xie
 */
@Service
public class OrderServiceImpl implements IOrderService {


    /**
     * @SentinelResource 不止针对路径参数，还可以针对方法，
     * 但是此场景拦截不到BlockException，所以BlockExceptionHandler不起作用，需要重新实现blockHandler
     * @return java.lang.String
     */
    @SentinelResource(value = "getUser", blockHandler = "blockHandlerGetUser")
    public String getUser() {
        return "查询用户";
    }

    public String blockHandlerGetUser(BlockException e) {
        e.printStackTrace();
        return "查询用户-被限流了";
    }
}
